﻿using RFID.Model;
using System.Collections.Generic;
using System.Linq;

namespace RFID.BLL
{
    public class StuInfoBLL
    {
        /// <summary>
        /// 查询未开卡或指定卡号的学生
        /// </summary>
        /// <param name="key">卡号或学号</param>
        /// <returns>学生列表</returns>
        public static List<StuInfo> Select(string key = "")
        {
            using (RFIDDataContext db = new RFIDDataContext())
            {
                return db.StuInfo.Where(p => string.IsNullOrEmpty(key) ? p.CardInfo.Count == 0 : p.CardInfo.Count(c => c.Id == key) > 0).ToList();
            }
        }
    }
}
